﻿using PRO.Admin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PRO.Common;

namespace web.Manage
{
    public partial class rePwd : ManageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (this.txtOldPwd.Text.IsNullOrWhiteSpace())
            {
                lblMsg.Text = "请输入您现在的密码！";
                return;
            }
            if (this.txtNewPwd.Text.IsNullOrWhiteSpace())
            {
                lblMsg.Text = "请输入新的密码！";
                return;
            }
            if (this.txtRePwd.Text.IsNullOrWhiteSpace())
            {
                lblMsg.Text = "请再输入一遍！";
                return;
            }
            if (!this.txtRePwd.Text.Equals(this.txtNewPwd.Text))
            {
                lblMsg.Text = "两次输入的密码不一致！";
                return;
            }
            if(AdminLib.RePwd(admininfo.ID,Utils.MD5(txtOldPwd.Text),Utils.MD5(txtNewPwd.Text)))
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('修改成功，需要重新登陆！');</script>");
            else
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('修改失败，可能旧密码不正确！');</script>");
        }
    }
}